﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;

namespace Future.FormBase
{
    public class DevBarRegister : IToolbarRegister
    {
        private DevExpress.XtraBars.Bar _bar;
        private Form _Owner;

        public DevBarRegister(DevExpress.XtraBars.Bar bar, Form owner)
        {
            _bar = bar;
            _Owner = owner;
        }

        #region IToolbarRegister 成员

        public void RegisterButton(System.Collections.IList buttons)
        {
            _bar.BeginUpdate();
            _bar.ItemLinks.Clear();
            foreach (IButtonInfo bi in buttons)
            {
                BarItem btn = bi.Button as BarItem;
                _bar.ItemLinks.Add(btn, bi.Group);
            }
            _bar.EndUpdate();
        }

        public void Dispose()
        {

        }

        public IButtonInfo CreateButton(string name, string caption, System.Drawing.Bitmap image, System.Drawing.Size size, OnButtonClick clickEvent)
        {
            return new DevBarButtonInfo(_bar.Manager, name, caption, image, size, clickEvent, false);
        }

        public IButtonInfo CreateButton(string name, string caption, System.Drawing.Bitmap image, System.Drawing.Size size, OnButtonClick clickEvent, bool group)
        {
            return new DevBarButtonInfo(_bar.Manager, name, caption, image, size, clickEvent, group);
        }

        #endregion
    }
}
